// @ts-ignore
/* eslint-disable */
import { request } from '@umijs/max';

/** 添加数据标准 POST /dataStandard/addDataStandard */
export async function addDataStandardUsingPost(
  body: dataFactory.AddDataStandardDTO_,
  options?: { [key: string]: any },
) {
  return request<dataFactory.R>('/dataStandard/addDataStandard', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 修改数据标准状态 PUT /dataStandard/changeStatus */
export async function changeStatusUsingPut(
  body: dataFactory.ChangeStandardStatusDTO,
  options?: { [key: string]: any },
) {
  return request<dataFactory.R>('/dataStandard/changeStatus', {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 删除数据标准 DELETE /dataStandard/deleteStandard/${param0} */
export async function deleteStandardUsingDelete(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: dataFactory.deleteStandardUsingDELETEParams,
  options?: { [key: string]: any },
) {
  const { standardId: param0, ...queryParams } = params;
  return request<dataFactory.R>(`/dataStandard/deleteStandard/${param0}`, {
    method: 'DELETE',
    params: { ...queryParams },
    ...(options || {}),
  });
}

/** 查询数据标准列表 POST /dataStandard/getDataStandardList */
export async function getDataStandardListUsingPost(
  body: dataFactory.QueryDataStandardDTO_,
  options?: { [key: string]: any },
) {
  return request<dataFactory.R>('/dataStandard/getDataStandardList', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 获取枚举范围 GET /dataStandard/getEnumRange/${param0} */
export async function getEnumRangeUsingGet(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: dataFactory.getEnumRangeUsingGETParams,
  options?: { [key: string]: any },
) {
  const { standardId: param0, ...queryParams } = params;
  return request<dataFactory.R>(`/dataStandard/getEnumRange/${param0}`, {
    method: 'GET',
    params: { ...queryParams },
    ...(options || {}),
  });
}

/** 标准导入 POST /dataStandard/importStandard */
export async function uploadCodeTableUsingPost1(
  body: {},
  file?: File,
  options?: { [key: string]: any },
) {
  const formData = new FormData();

  if (file) {
    formData.append('file', file);
  }

  Object.keys(body).forEach((ele) => {
    const item = (body as any)[ele];

    if (item !== undefined && item !== null) {
      if (typeof item === 'object' && !(item instanceof File)) {
        if (item instanceof Array) {
          item.forEach((f) => formData.append(ele, f || ''));
        } else {
          formData.append(ele, JSON.stringify(item));
        }
      } else {
        formData.append(ele, item);
      }
    }
  });

  return request<dataFactory.R>('/dataStandard/importStandard', {
    method: 'POST',
    data: formData,
    requestType: 'form',
    ...(options || {}),
  });
}

/** 修改数据标准 POST /dataStandard/updateStandard */
export async function updateDataStandardUsingPost(
  body: dataFactory.UpadateDataStandardDTO,
  options?: { [key: string]: any },
) {
  return request<dataFactory.R>('/dataStandard/updateStandard', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}
